package com.wkbb.sports.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * @Title: 时间计算，转换工具
 * @Description:
 * @author guanjingfen
 * @date 2018-04-11 11:03:47
 * @version V1.0
 *
 */
public class DateUtils {
	/**    
	 * 月份转化成英文单词    
	 * @param month    
	 * @return   
	 * */   
	public static String translateMonth(String month) {
		String res = "";
		if (month == null || month.trim().equals("")) {       
			res = "";   
		}else{          
			int mon = Integer.valueOf(month);     
			switch (mon) {     
				case 1:       
					res = "January";// Jan       
				break;     
				case 2:       
					res = "February";// Feb       
					break;     
					case 3:       
						res = "March";// Mar       
						break;    
					case 4:       
						res = "April";// Apr       
						break;     
					case 5:       
						res = "May";// May       
						break;     
					case 6:       
						res = "June";// Jun       
						break;     
					case 7:       
						res = "July";// Jul       
						break;     
					case 8:       
						res = "August";// Aug       
						break;     
					case 9:       
						res = "September";// Sep       
						break;     
					case 10:       
						res = "October";// Oct       
						break;     
					case 11:       
						res = "November";// Nov       
						break;     
					case 12:       
						res = "December";// Dec       
						break;     
					default:       
						res = "";     
				} 
			}
		return res; 
	}
	
	
	/**
	 * @param date
	 * @param minute
	 *        获取的日期与传入日期的差值： 比如想要获取传入日期前四分钟的日期 minute=-4即可
	 * @return
	 */
	public static Date getSomeMinute(Date date, int minute) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.MINUTE, minute);
		return calendar.getTime();
	}
	
	/**
	 * @param date
	 * @param hour
	 *        获取的日期与传入日期的差值： 比如想要获取传入日期前四小时的日期 hour=-4即可
	 * @return
	 */
	public static Date getSomeHour(Date date, int hour) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.HOUR, hour);
		return calendar.getTime();
	}
	
	/**
	 * @param date
	 * @param day
	 *        获取的日期与传入日期的差值 ：比如想要获取传入日期前四天的日期 day=-4即可
	 * @return
	 */
	public static Date getSomeDay(Date date, int day) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.DATE, day);
		return calendar.getTime();
	}
	
	/**
	 * @param date
	 * @param month
	 *        获取的日期与传入日期的差值： 比如想要获取传入日期前四月的日期 month=-4即可
	 * @return
	 */
	public static Date getSomeMonth(Date date, int month) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.MONTH, month);
		return calendar.getTime();
	}
	
	
	/**
	 * @param int
	 * 传入正数，返回负值
	 * @return
	 */
	public static int unAbs(int a) {
        return (a > 0) ? -a : a;
    }
}
